// 这就是menu的独立模块
import {menuList} from '../../../request/api'

const state = {
    menulist:[]
}

const getters = {
    getMenu(state){
        return state.menulist
    }
}

const mutations = {
    GET_MENULIST(state,payload){
        state.menulist = payload
    }
}

const actions = {
    // 封装一个获取列表的行动
    getMenuListActions({commit}){
        // 调用接口
        menuList({
            istree:1
        })
        .then(res=>{
            // console.log(res);
            if(res.code == 200){
                commit('GET_MENULIST',res.list)
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced:true
}